package com.zimmor.workqueue;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.zimmor.util.RabbitmqUtil;

import java.io.IOException;

/**
 * @Author:zimmor
 * @Date: 2021/12/28 18:47
 * @Description 工作队列 也被称为 Task queues 任务模型 多个队列共同消费一个队列中的消息
 * @version: 1.0.0
 */

public class Provider {
    public static void main(String[] args) {
        Connection connection = RabbitmqUtil.getConnection();
        try {
             Channel channel = connection.createChannel();
            channel.queueDeclare("workqueue", false, false, false, null);
            for (int i = 0; i < 10; i++) {
             channel.basicPublish("", "workqueue", null, (i+"work queue 中的消息").getBytes());
            }
            RabbitmqUtil.close(channel, connection);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
